clear all

cd "[INSERT FILE DIRECTORY HERE]"
use "[INSERT FILE LOCATION HERE]"

*The following plugins are required to produce some of the graphs
ssc install vioplot
ssc install combomarginsplot

set more off

******************************DESCRIPTIVES****************************************

*Figure 1

vioplot mfq_ind_a mfq_bin_a, over(house_des, total) scheme(plotplain) saving(v2.gph)

*******************************ANALYSIS*******************************

xtset interview_neigh

*********************************************MAIN ANALYSIS******************************************

*Tests of the effect of house_des on morality (Tables S7-S8)

*Naive model
xtreg mfq_ind_a house_des, fe
est store I1
outreg2 using mfq_ind_a1.doc
margins, at(house_des=(0(1)1)) post saving(file1, replace)
xtreg mfq_bin_a house_des, fe
est store B1
outreg2 using mfq_bin_a1.doc
margins, at(house_des=(0(1)1)) post saving(file2, replace)

*Only violence types
xtreg mfq_ind_a house_des injury fam_injury fam_kill, fe
est store I2
outreg2 using mfq_ind_a1.doc
margins, at(house_des=(0(1)1)) post saving(file1, replace)
xtreg mfq_bin_a house_des injury fam_injury fam_kill, fe
est store B2
outreg2 using mfq_bin_a1.doc
margins, at(house_des=(0(1)1)) post saving(file2, replace)

*Full model
xtreg mfq_ind_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2, fe
est store I3
outreg2 using mfq_ind_a1.doc
margins, at(house_des=(0(1)1)) post saving(file1, replace)
xtreg mfq_bin_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2, fe
est store B3
outreg2 using mfq_bin_a1.doc
margins, at(house_des=(0(1)1)) post saving(file2, replace)

*Only targeted by chance
xtreg mfq_ind_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2 if resp_2 == 0, fe
est store I4
outreg2 using mfq_ind_a1.doc
margins, at(house_des=(0(1)1)) post saving(file1, replace)
xtreg mfq_bin_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2 if resp_2 == 0, fe
est store B4
outreg2 using mfq_bin_a1.doc
margins, at(house_des=(0(1)1)) post saving(file2, replace)

*Targeted directly
xtreg mfq_ind_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2 if resp_2 == 1, fe
est store I5
outreg2 using mfq_ind_a1.doc
margins, at(house_des=(0(1)1)) post saving(file1, replace)
xtreg mfq_bin_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2 if resp_2 == 1, fe
est store B5
outreg2 using mfq_bin_a1.doc
margins, at(house_des=(0(1)1)) post saving(file2, replace)

*Figure 2
coefplot I1 B1 I2 B2 I3 B3 I4 B4, keep(house_des) scheme(plotplain)



*****************************PART II - EXPERIMENT WITH WTR************************************************

*Excluding obs who did not self identify as Sunni Arab.
drop if rel!=1
drop if eth!=1

*With no interactions (main effects only) (Tables S9, S16 & S18)
xtreg wtr wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_wtr_main.doc

xtreg emotion wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotion_main.doc

xtreg threat wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_threat_main.doc

*With interactions (Tables S10, S17 & S19)
xtreg wtr wtr_sunni##c.mfq_ind_a i.wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_wtr.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot 
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(g3_1.gph)
margins, dydx(wtr_sunni) at(mfq_ind_a=(1(1)6))
margins, dydx(wtr_sunni) at(mfq_ind_a=4.328)
margins, dydx(wtr_sunni) at(mfq_ind_a=2.967)

xtreg emotion wtr_sunni##c.mfq_ind_a wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotions1.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(emo_gr.gph)
margins, dydx(wtr_sunni) at(mfq_ind_a=(1(1)6))
margins, dydx(wtr_sunni) at(mfq_ind_a=4.328)
margins, dydx(wtr_sunni) at(mfq_ind_a=2.967)

xtreg threat wtr_sunni##c.mfq_ind_a wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_threats1.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(thr_gr.gph)
margins, dydx(wtr_sunni) at(mfq_ind_a=(1(1)6))
margins, dydx(wtr_sunni) at(mfq_ind_a=4.328)
margins, dydx(wtr_sunni) at(mfq_ind_a=2.967)

*Figure 3
graph combine g3_1.gph emo_gr.gph thr_gr.gph, xcommon col(2)



*******************************************SUPPLEMETARY MATERIALS**********************************************
***************************************************************************************************************

*********************************************Balance tests*****************************************************

*For now, we need to take back the full data set
clear

cd "[INSERT FILE DIRECTORY HERE]"
use "[INSERT FILE LOCATION HERE]"

*Balance tests of whether violence was "as-if-random" (Tables S3-S6)

xtset interview_neigh

*what explains house destruction?
xtlogit house_des female age edu ses_2003_2 ses_2014_2, fe
outreg2 using mfq_bal1.doc

*doing the same with the other exposure types

*what explains injury?
xtlogit injury female age edu ses_2003_2 ses_2014_2, fe
outreg2 using mfq_bal2.doc

*what explains fam_injury?
xtlogit fam_injury female age edu ses_2003_2 ses_2014_2, fe
outreg2 using mfq_bal3.doc

*what explains fam_kill?
xtlogit fam_kill female age edu ses_2003_2 ses_2014_2, fe
outreg2 using mfq_bal4.doc


*************************************Analysis of separate foundations******************************************

*Figure S4

vioplot mfq_care_a mfq_fair_a mfq_loya_a mfq_auth_a mfq_sanc_a, over(house_des) scheme(plotplain)

*Analysing each foundation (Tables S11-S15)

*Naive model
xtreg mfq_care_a house_des, fe
outreg2 using mfq_care_A.doc
margins, at(house_des=(0(1)1)) post saving(file1, replace)
xtreg mfq_fair_a house_des, fe
outreg2 using mfq_fair_A.doc
margins, at(house_des=(0(1)1)) post saving(file2, replace)
xtreg mfq_loya_a house_des, fe
outreg2 using mfq_loya_A.doc
margins, at(house_des=(0(1)1)) post saving(file3, replace)
xtreg mfq_auth_a house_des, fe
outreg2 using mfq_auth_A.doc
margins, at(house_des=(0(1)1)) post saving(file4, replace)
xtreg mfq_sanc_a house_des, fe
outreg2 using mfq_sanc_A.doc
margins, at(house_des=(0(1)1)) post saving(file5, replace)


*With all exposure types

xtreg mfq_care_a house_des injury fam_injury fam_kill, fe
outreg2 using mfq_care_A.doc
margins, at(house_des=(0(1)1)) post saving(file1, replace)
xtreg mfq_fair_a house_des injury fam_injury fam_kill, fe
outreg2 using mfq_fair_A.doc
margins, at(house_des=(0(1)1)) post saving(file2, replace)
xtreg mfq_loya_a house_des injury fam_injury fam_kill, fe
outreg2 using mfq_loya_A.doc
margins, at(house_des=(0(1)1)) post saving(file3, replace)
xtreg mfq_auth_a house_des injury fam_injury fam_kill, fe
outreg2 using mfq_auth_A.doc
margins, at(house_des=(0(1)1)) post saving(file4, replace)
xtreg mfq_sanc_a house_des injury fam_injury fam_kill, fe
outreg2 using mfq_sanc_A.doc
margins, at(house_des=(0(1)1)) post saving(file5, replace)


*With some additional contols

xtreg mfq_care_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2, fe
est store C1
outreg2 using mfq_care_A.doc
margins, at(house_des=(0(1)1)) post saving(file1, replace)
xtreg mfq_fair_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2, fe
est store F1
outreg2 using mfq_fair_A.doc
margins, at(house_des=(0(1)1)) post saving(file2, replace)
xtreg mfq_loya_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2, fe
est store L1
outreg2 using mfq_loya_A.doc
margins, at(house_des=(0(1)1)) post saving(file3, replace)
xtreg mfq_auth_a house_des injury fam_injury fam_kill female age edu  ses_2003_2 ses_2014_2, fe
est store A1
outreg2 using mfq_auth_A.doc
margins, at(house_des=(0(1)1)) post saving(file4, replace)
xtreg mfq_sanc_a house_des injury fam_injury fam_kill female age edu  ses_2003_2 ses_2014_2, fe
est store S1
outreg2 using mfq_sanc_A.doc
margins, at(house_des=(0(1)1)) post saving(file5, replace)


*With only those who reported random harm (from isf or is)

xtreg mfq_care_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2 if resp_2==0, fe
est store C2
outreg2 using mfq_care_A.doc
margins, at(house_des=(0(1)1)) post saving(file1, replace)
xtreg mfq_fair_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2 if resp_2==0, fe
est store F2
outreg2 using mfq_fair_A.doc
margins, at(house_des=(0(1)1)) post saving(file2, replace)
xtreg mfq_loya_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2 if resp_2==0, fe
est store L2
outreg2 using mfq_loya_A.doc
margins, at(house_des=(0(1)1)) post saving(file3, replace)
xtreg mfq_auth_a house_des injury fam_injury fam_kill female age edu  ses_2003_2 ses_2014_2 if resp_2==0, fe
est store A2
outreg2 using mfq_auth_A.doc
margins, at(house_des=(0(1)1)) post saving(file4, replace)
xtreg mfq_sanc_a house_des injury fam_injury fam_kill female age edu  ses_2003_2 ses_2014_2 if resp_2==0, fe
est store S2
outreg2 using mfq_sanc_A.doc
margins, at(house_des=(0(1)1)) post saving(file5, replace)

*Excluding those who reported random harm (from isf or is)

xtreg mfq_care_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2 if resp_2==1, fe
outreg2 using mfq_care_A.doc
margins, at(house_des=(0(1)1)) post saving(file1, replace)
xtreg mfq_fair_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2 if resp_2==1, fe
outreg2 using mfq_fair_A.doc
margins, at(house_des=(0(1)1)) post saving(file2, replace)
xtreg mfq_loya_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2 if resp_2==1, fe
outreg2 using mfq_loya_A.doc
margins, at(house_des=(0(1)1)) post saving(file3, replace)
xtreg mfq_auth_a house_des injury fam_injury fam_kill female age edu  ses_2003_2 ses_2014_2 if resp_2==1, fe
outreg2 using mfq_auth_A.doc
margins, at(house_des=(0(1)1)) post saving(file4, replace)
xtreg mfq_sanc_a house_des injury fam_injury fam_kill female age edu  ses_2003_2 ses_2014_2 if resp_2==1, fe
outreg2 using mfq_sanc_A.doc
margins, at(house_des=(0(1)1)) post saving(file5, replace)

*We also include the individualizing and binding measures for comparison

xtreg mfq_ind_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2, fe
est store I3
xtreg mfq_bin_a house_des injury fam_injury fam_kill female age edu ses_2003_2 ses_2014_2, fe
est store B3

*Figure S5
coefplot I3 C1 F1 B3 L1 A1 S1, keep(house_des) scheme(plotplain)

*********************************************Tests of separate threats and emotions****************************


*Excluding obs who did not self identify as Sunni Arab.
drop if rel!=1
drop if eth!=1



*THREATS
*Running full main and interaction models for all threat types (Table S16-S17)

xtreg val_t wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_threat_main.doc

xtreg val_t wtr_sunni##c.mfq_ind_a wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_threats1.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(val_gr.gph)


xtreg phy_t wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_threat_main.doc

xtreg phy_t wtr_sunni##c.mfq_ind_a wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_threats1.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(phy_gr.gph)


xtreg job_t wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_threat_main.doc

xtreg job_t wtr_sunni##c.mfq_ind_a wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_threats1.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(job_gr.gph)


xtreg dis_t wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_threat_main.doc

xtreg dis_t wtr_sunni##c.mfq_ind_a wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_threats1.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(dis_gr.gph)

*Figure S6
graph combine val_gr.gph phy_gr.gph job_gr.gph dis_gr.gph, ycommon


*EMOTIONS
*Running full main and interaction models for all emotions (Table S18-S19)

xtreg empathy wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotion_main.doc

xtreg empathy wtr_sunni##c.mfq_ind_a wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotions1.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(emp_gr2.gph)

xtreg respect wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotion_main.doc

xtreg respect wtr_sunni##c.mfq_ind_a wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotions1.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(res_gr2.gph)

xtreg fear wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotion_main.doc

xtreg fear wtr_sunni##c.mfq_ind_a wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotions1.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(fea_gr2.gph)

xtreg anger wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotion_main.doc

xtreg anger wtr_sunni##c.mfq_ind_a wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotions1.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(ang_gr2.gph)

xtreg disgust wtr_sunni c.mfq_ind_a c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotion_main.doc

xtreg disgust wtr_sunni##c.mfq_ind_a wtr_sunni##c.mfq_bin_a female age edu ses_2003 ses_2014 wtr_female wtr_old, fe
outreg2 using mfq_emotions1.doc
margins wtr_sunni, at(mfq_ind_a=(1(1)6))
*marginsplot
marginsplot, yline(0) scheme(plotplain) recast(line) recastci(rarea) saving(dis_gr2.gph)

*Figure S7
graph combine emp_gr2.gph res_gr2.gph fea_gr2.gph ang_gr2.gph dis_gr2.gph, ycommon

